You are here: VBScript examples > Sending email messages

Sending email messages

Automatically generating email messages is useful for many purposes, particularly during customized event procedures. The following example code shows a typical procedure for setting properties of a NewMailMessage object. It uses constants in the AS_MAPIMSG_RECIP_TYPE and AS_MAPIMSG_SEND_FLAGS enumerations to set various properties of the message before sending it.

Sub SendEmailMessage()
    Dim oMessage
    Set oMessage = Client.NewMailMessage

    'Recipients
    oMessage.Recipients.Add "",AS_MMRT_TO,"<recipient.name@anotherdomain.com>"
    oMessage.Recipients.Add "",AS_MMRT_CC,"<recipient.name@anotherdomain.com>"

    'Sender
    oMessage.Originator.Address = "<sender.name@mydomain.com>"
    oMessage.Originator.Name = "Sender's Name"
    oMessage.Originator.Type = AS_MMRT_ORIG

    'Subject
    oMessage.Subject = "The subject of the message"

    'Body text
    oMessage.NoteText = "The body text of the message"

    'Attachments
     oMessage.Attachments.Add "c:\temp\my.bmp", ""

    'Send it with MAPI options and reset when done
    oMessage.Send AS_MMSF_LOGON_UI
    oMessage.Clean
End Sub

Related concepts

VBScript examples

Validating unique property values

Clearing the property values of copied documents

Setting property values based on workflow transitions

About the NewMailMessage object

About the MailRecipients object

About the MailRecipient object

About the MailMessage object

Related information

The Meridian API constants

Attachments property

NoteText property

Originator property

Recipients property

Subject property

Clean method

Send method

Count property

Recipient property

Add method

Remove method

RemoveAll method

Address property

Name property

Type property

Attachments property

NoteText property

Originator property

Recipients property

Subject property

Clean method

Send method


www.bluecieloecm.com